<?php
namespace application\system\model\auth;
/**
 * Description of Model
 *
 * Model 	: roleHierarchy
 * Created	: 02Oct2014
 * Purpose 	: Role Hierarchy Model
 *
 * Change Logs
 * -----------------------------------------------------------
 * 02Oct2014 admin: Created the model roleHierarchy
 *  
 * @author admin
 *
 * Properties
 * @property String $parent_role_title Parent role title
 * @property String $child_role_title Child role title
 */
class RoleHierarchy extends \simbola\core\application\AppModel{
    static  //config params
            $table_name, 
            $primary_key, 
            $class_name, 
            //state machine
            $state_config,
            //relationships
            $has_many = array(), 
            $belongs_to = array(), 
            //alias
            $alias_attribute = array(),
            //validations system
            $validates_uneditable = array(),
            //validations php-ar 
            $validates_presence_of = array(),
            $validates_size_of = array(),
            $validates_length_of = array(),
            $validates_exclusion_of = array(),
            $validates_inclusion_of = array(),
            $validates_format_of = array(),
            $validates_numericality_of = array(),
            $validates_uniqueness_of = array();

    public static function initialize() {
        //Model Setup
        self::setClass(__CLASS__);
        self::setSource('system', 'auth', 'role_hierarchy');
        self::primaryKey(array('parent_role_title','child_role_title'));        

        //Relationships - Has Many
        //None

        //Relationships - Belongs To
        self::belongsTo(array('child', 'class_name' => '\application\system\model\auth\Role', 'foreign_key' => 'child_role_title', 'primary_key' => 'title'));
        self::belongsTo(array('parent', 'class_name' => '\application\system\model\auth\Role', 'foreign_key' => 'parent_role_title', 'primary_key' => 'title'));

        //Validations
        // - parent_role_title
        self::validatePresenceOf(array("parent_role_title"));
        self::validateSizeOf(array("parent_role_title", "maximum" => 100));
        // - child_role_title
        self::validatePresenceOf(array("child_role_title"));
        self::validateSizeOf(array("child_role_title", "maximum" => 100));
    }
}

?>
